#pragma once
#include "rbtree.hpp"

namespace Aurora
{
	template<class K,class V>
	class map
	{
		struct MapKeyOfT
		{
			const K& operator()(const std::pair<K, V>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename RBTree< K, std::pair<const K, V>, MapKeyOfT>::Iterator iterator;
		typedef typename RBTree< K, std::pair<const K, V>, MapKeyOfT>::ConstIterator const_iterator;
		//typedef typename RBTree<K, std::pair<K, V>, MapKeyOfT>::Iterator iterator;
		iterator begin()
		{
			return _t.Begin();
		}
		iterator end()
		{
			return _t.End();
		}
		const_iterator begin() const
		{
			return _t.Begin();
		}
		const_iterator end() const
		{
			return _t.End();
		}
		iterator find(const K& key)
		{
			return _t.Find(key);
		}
		std::pair<iterator,bool> insert(const std::pair<K, V>& kv)
		{
			return _t.insert(kv);
		}
		V& operator[](const K& key)
		{
			std::pair<iterator,bool> f = _t.insert(std::make_pair(key,V()));
			return f.first->second;

		}
	private:
		RBTree< K, std::pair<const K, V>, MapKeyOfT> _t;
	};
}